package com.slipper.system.flow.service;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import com.slipper.system.flow.dao.FlowInstNodeDao;
import com.slipper.system.flow.bo.FlowInstNodeBO;
import com.slipper.core.transaction.ReadTransactional;
import com.slipper.core.transaction.WriteTransactional;
import com.slipper.util.Tool;

@Service
@ReadTransactional
public class FlowInstNodeService {
    @Resource
    private FlowInstNodeDao flowInstNodeDao;
    
    public FlowInstNodeBO queryBy(String id){
        return flowInstNodeDao.queryBy(id);
    }

    public List<FlowInstNodeBO> queryListByInstId(String instId) {
        return flowInstNodeDao.queryListByInstId(instId);
    }
    
    public List<FlowInstNodeBO> queryList(FlowInstNodeBO bo) {
        return flowInstNodeDao.queryList(bo);
    }
    
    public PageInfo<FlowInstNodeBO> queryPage(FlowInstNodeBO bo){
        PageHelper.startPage(bo.getPageNumber(), bo.getPageSize());
        return new PageInfo<>(flowInstNodeDao.queryList(bo));
    }
    
    @WriteTransactional
    public Integer save(FlowInstNodeBO bo){
        int result;
        if (bo.getId() != null && !"".equals(bo.getId())) {
            bo.setUpdateTime(System.currentTimeMillis());
            result = flowInstNodeDao.update(bo);
        } else {
            bo.setId(Tool.getUUID());
            bo.setUpdateTime(System.currentTimeMillis());
            bo.setCreateTime(System.currentTimeMillis());
            result = flowInstNodeDao.insert(bo);
        }
        
        return result;
    }
    
    @WriteTransactional
    public Integer delete(FlowInstNodeBO bo){
        return flowInstNodeDao.delete(bo);
    }

    @WriteTransactional
    public int deleteByInstId(String instId) {
        return flowInstNodeDao.deleteByInstId(instId);
    }
}
